<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>华猫商城</title>
		<style></style>
		<link href="../css/jquery.validator.css" rel="stylesheet">
		<link href="../css/common.css" rel="stylesheet">

		<link href="../plugin/userLib/css/user.css" rel="stylesheet">
		<link href="../plugin/userLib/css/userinfo.css" rel="stylesheet">
		<link href="../plugin/userLib/css/my_user.css" rel="stylesheet">
		<link href="../css/base.css" rel="stylesheet">
		<style>

		</style>
	</head>

	<body>
		<div id="header"></div>
		<div id="headerBox"></div>
		<!--<div id="nav_menu"></div>-->
		<div class="ZZHT-wrap">
			<div class="ZZHT-header" style="border-bottom: 1px solid #ffffff;">
				<div class="ZZHT-shop-nav">
					<div class="ZZHT-nav-box">
						<a href="#">
							<li class="liselect ZZHT-lfloat ZZHT-nav-boxa">用户中心</li>
						</a>
						<div class="ZZHT-clear"></div>
					</div>
				</div>
				<div class="ZZHT-clear"></div>
			</div>
			<div class="ZZHT-main">
				<div id="user_left"></div>
				<div class="ZZHT-content">

					<div class="ZZHT-user-head clearfix">
						<b>用户升级</b>
						<span class="user_bread fr">
        当前位置：<span>用户身份</span>--<span>用户升级</span>
						</span>
					</div>
					<div class="mains bz">
						<!-- 个人升级主管 -->
						<form action="##">
							<div class="form-group clearfix">
								<label class="control-label fl"><span class="text-label">升级为：</span></label>
								<div class="fl clearfix">
									<div class="fl" style="margin-right: 20px;">
										<!--[if !IE]><!-->
										<div class="ui-checkbox zhuG">
											<input type="checkbox" checked="checked" class="ipt" name="type" value="1">
											<label></label>
										</div>
										<span>主管</span>
									</div>
									<div class="fl">
										<!--[if !IE]><!-->
										<div class="ui-checkbox jinL">
											<input type="checkbox" class="ipt" name="type" value="2">
											<label></label>
										</div>
										<span id="jingli">经理</span>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">
            <span class="text-label">支付金额：</span>
            <input type="text" name="pay_money" value="" class="ipt" id="money" disabled="disabled">
          </label>
							</div>
							<div class="form-group">
								<label class="control-label">
            <span class="text-label">获得积分：</span>
            <input type="text" name="get_jifen" value="" class="ipt" id="jifen" disabled="disabled">
          </label>
							</div>
							<div class="sure_btn confirm_pay">确定支付</div>
						</form>
					</div>

				</div>
			</div>
			<div style="clear:both;"></div>
			<br>
		</div>
		<div id="ck3"></div>
		<script src="../js/jquery.min.js"></script>
		<script src="../plugin/layer/layer.js"></script>
		<script type="text/javascript" src="../js/ljf_base.js"></script>
		<script type="text/javascript" src="../plugin/userLib/js/security.js"></script>
		<script type="text/javascript">
			$(function() {
				$.ajax({
					type: "post",
					url: SURL + "webAccount/getUseUpDate",
					data: {
						userId: localStorage.userId
					},
					dataType: 'json',
					success: function(res) {
						var res = res.entity;
						if(res.code == 01) {
							if(res.upAgentAccount) { //普通用户
								$('input[name="pay_money"]').attr("value", res.upAgentAccount);
								$('input[name="get_jifen"]').attr("value", res.upAgentScore);
								$(".jinL").click(function(e) {
									var chk = $(this).children("input");
									var check = chk.attr("checked");
									if(check) return;
									$(".zhuG").children("input").attr("checked", false);
									chk.attr("checked", check ? false : true);
									$('input[name="pay_money"]').attr("value", res.upManagerAccount);
									$('input[name="get_jifen"]').attr("value", res.upManagerScore);
								});
								$(".zhuG").click(function(e) {
									var chk = $(this).children("input");
									var check = chk.attr("checked");
									if(check) return;
									$(".jinL").children("input").attr("checked", false);
									chk.attr("checked", check ? false : true);
									$('input[name="pay_money"]').attr("value", res.upAgentAccount);
									$('input[name="get_jifen"]').attr("value", res.upManagerAccount);
								});
							} else { //主管升级经理
								$('input[name="pay_money"]').attr("value", res.upManagerAccount);
								$('input[name="get_jifen"]').attr("value", res.upManagerScore);
								$(".zhuG").children("input").attr("checked", false);
								$(".zhuG").parent('.fl').hide();
								$(".jinL").children('input').attr('checked', true);
							}
						} else {
							layer.msg(res.msg);
						}
					}
				});
			});

			$(".confirm_pay").click(function() {//确认支付
				var ll = layer.msg('数据处理中，请稍候...');
				var params = {};
				params['userId'] = localStorage.userId;
				params['userUpType'] = $("input[name=type][checked=checked]").val();
				$.ajax({
					type: "post",
					url: SURL + "webAccount/getCashToUp",
//					url:  "http://192.168.43.17/webAccount/getCashToUp",
					data: params,
					dataType: 'json',
					success: function(res) {
						var res = res.entity;
						if(res.code == 01) {
							console.log(res);
							layer.close(ll);
							var orderId = res.orderId;
							var money = res.upAccount;
							localStorage.payData = JSON.stringify(res);
							location.href="../carts/checkout_grade.html?orderId="+orderId+'&money='+money+'&path=webAccount/toUpPay';
						} else {
							layer.close(ll);
							layer.msg(res.msg);
						}
					}
				});
			})
		</script>
	</body>

</html>